import 'package:flutter/material.dart';

//真正的组件类 用于接收外部传入的数据
class StatefullCase extends StatefulWidget {
  //
  const StatefullCase({super.key, this.title = '状态管理'});
  final String title;

  @override
  createState() => _StatefullCaseState();
}

//组件状态类  单独管理 组件的状态
class _StatefullCaseState extends State<StatefullCase> {
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          Text(widget.title.toString()),
          ElevatedButton(
              onPressed: () {
                setState(() {
                  count++;
                });
              },
              child: Text('点击+1---- $count'))
        ],
      ),
    );
  }
}
